<!--
 * @Author: your name
 * @Date: 2021-12-23 08:48:45
 * @LastEditTime: 2021-12-31 08:57:58
 * @LastEditors: hyman
 * @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 * @FilePath: \shop\src\components\user\base\index.vue
-->
<template>
  <!-- 基本资料 -->
  <div class="myBox" :style="{ background: 'url(' + LoginUser.cover + ')' }" style="background-size: cover;background-position:center;">
    <div class="L"><img :src="LoginUser.avatar" /></div>
    <div class="C">
      <div class="tit">{{ LoginUser.nickname }}</div>
      <div class="sub">{{ LoginUser.createtime }}</div>
    </div>
    <!-- <div class="R">
            <img src="/assets/images/go.png" />
        </div> -->
  </div>
  <div class="clear"></div>
  <div class="allkbox"></div>

  <div class="myboxcon">
    <router-link to="/user/base/profile">
      <p>个人资料</p>
      <img src="/assets/images/go.png" />
    </router-link>
  </div>
  <div class="myboxcon" v-if="LoginUser.auth == 0" @click="attestation">
    <div>
      <p>帐号认证</p>
      <img src="/assets/images/go.png" />
    </div>
  </div>
  <div class="myboxcon">
    <router-link to="/user/address/index">
      <p>收货地址</p>
      <img src="/assets/images/go.png" />
    </router-link>
  </div>
  <div class="myboxcon">
    <router-link to="/user/order/index">
      <p>我的订单</p>
      <img src="/assets/images/go.png" />
    </router-link>
  </div>
  <div class="myboxcon">
    <router-link to="/user/base/record">
      <p>消费记录</p>
      <img src="/assets/images/go.png" />
    </router-link>
  </div>
  <div class="myboxcon">
    <router-link to="/user/base/deposit">
      <p>充值中心</p>
      <img src="/assets/images/go.png" />
    </router-link>
  </div>
  <div class="myboxcon">
    <router-link to="/user/base/rechargerecord">
      <p>充值记录</p>
      <img src="/assets/images/go.png" />
    </router-link>
  </div>
  <div class="myboxcon" @click="logout">
    <p>退出登陆</p>
    <img src="/assets/images/go.png" />
  </div>
  <div class="clear"></div>
  <div class="h54"></div>
</template>
<script>
export default {
  name: "BaseIndex",
  emits: ["toggle"],
  created() {
    this.$emit("toggle", true);
  },
  data() {
    return {
      LoginUser: this.$cookies.get("LoginUser"),
    };
  },
  methods: {
    logout() {
      this.$dialog
        .confirm({
          title: "退出",
          message: "是否确认退出",
        })
        .then(() => {
          //删除cookie
          this.$cookies.remove("LoginUser");

          //页面跳转
          this.$router.push("/user/base/login");

          return;
        })
        .catch(() => {});
    },
    attestation() {
      this.$dialog
        .confirm({
          title: "邮箱认证",
          message: "是否发送邮箱获取验证码认证",
        })
        .then(async () => {
          let result = await this.$api.email({ userid: this.LoginUser.id });

          if (result.code == "1") {
            //提醒信息
            this.$notify({
              type: "success",
              message: result.msg,
              duration: 1000,
              onClose: () => {
                this.$router.push("/user/base/verification");
              },
            });
          } else {
            //提醒信息
            this.$notify({
              message: result.msg,
              duration: 1000,
            });
          }
        })
        .catch(() => {});
    },
  },
};
</script>
<style>
.myboxcon a {
  display: block;
  width: 100%;
  height: 100%;
}

.myboxcon p {
  margin-top: 0;
}
</style>